package cz.uvn.orthopedy.client.ui;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

public final class UIUtils {
	
	private UIUtils() {
	}
	
	public static void handleError(Throwable error) {
		Window.alert(error.getMessage());
//		if (error instanceof NotLoggedInException) {
//			Window.Location.replace(loginInfo.getLogoutUrl());
//		}
	}

	public static void message(String text) {
		Window.alert(text);
	}
	
	public static void showWaitCursor() {
	    DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "wait");
	}
	 
	public static void showDefaultCursor() {
	    DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default");
	}

	public static Widget getBooleanWidget(boolean value) {
		CheckBox box = new CheckBox();
		box.setValue(value);
		box.setEnabled(false);
		return box;
	}
}
